package web.mb;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import metier.entities.Airport;
import metier.entities.Declaration;
import metier.entities.Employe;
import metier.entities.Etat;
import metier.entities.Gare;
import metier.entities.Message;
import metier.entities.Offre;
import metier.entities.Pays;
import metier.entities.Port;
import metier.entities.Station;
import metier.entities.SubCategorie;
import metier.entities.Ville;
import metier.entities.categorie;
import metier.sess.IDeclarationLocal;
import metier.sess.IEtatLocal;
import metier.sess.IMessageLocal;
import metier.sess.IOffreLocal;
import metier.sess.IPaysLocal;
import metier.sess.IStationLocal;
import metier.sess.ISubCategorieLocal;
import metier.sess.IUtilisateurLocal;
import metier.sess.IVilleLocal;


@ManagedBean
@ViewScoped
public class SearchFreightMB {
	
	@EJB
	private IStationLocal metierStation;
	
	@EJB 
	private IPaysLocal meteirp;
	
	@EJB
	private IEtatLocal metiere;
	
	@EJB 
	private IVilleLocal meteirv;
	
	@EJB
	private ISubCategorieLocal metiersub;
	
	@EJB
	private IOffreLocal metier;
	
	@EJB 
	private IMessageLocal metierMessage;
	
	@EJB
	private IUtilisateurLocal metierClient;
	
	@EJB
	private IDeclarationLocal metierDec;
	
	//parametres des enchères
	 Integer minutes=6;
	
		// for road
	//pickup
		//country,state,city 
		  private Integer IdS=new Integer(0);
		  private Integer IdC=new Integer(0);
		  private Integer IdCi=new Integer(0);	
		//list  country,state,city for pickup
		  private Set<Etat> listeEtat;
		  private Set<Ville> listeVille;
		  
		  
		//delivery
	     private Integer IdScm=new Integer(0);
		 private Integer IdCcm=new Integer(0);
		 private Integer IdCicm=new Integer(0);
		//list  country,state,city for  delivery
	     private Set<Etat> listeEtatcm;
		 private Set<Ville> listeVillecm;
		  
		//date fin
	   private Date Datefin;
		//date début
		private Date dateDebut;
		
		//category
		private Integer IdCategory=new Integer(0);
		 private boolean urgent=true;
		
//for rail
		 
		 //type de transport
		 private String typeR;
		 
		 //visibilité
		 
		 //by rail
		 //contry,state,city
		 private boolean redredPRail=false;
		 private boolean redredDRail=false;
		 //station
		 private boolean redredSPRail=false;
		 private boolean redredSDRail=false;
		 
		 //by Sea
		 private boolean redredPSea=false;
		 private boolean redredDSea=false;
		 //port
		 private boolean redredSPSea=false;
		 private boolean redredSDSea=false;
		 
		 
		 //by Air
		 private boolean redredPAir=false;
		 private boolean redredDAir=false;
		 //AirPort
		 private boolean redredSPAir=false;
		 private boolean redredSDAir=false;
		 
		 
		 
		 
		 
		//pickup
		//country,state,city 
		  private Integer IdSRa=new Integer(0);
		  private Integer IdCRa=new Integer(0);
		  private Integer IdCiRa=new Integer(0);	
		//list  country,state,city for pickup
		  private Set<Etat> listeEtatRa;
		  private Set<Ville> listeVilleRa;
		  
		// identifiant de la gare du train
		 private Integer IdPRail=new Integer(0);
		 private List<Station> listeGareP=new ArrayList<Station>();
		  
		//delivery
	     private Integer IdScmRa=new Integer(0);
		 private Integer IdCcmRa=new Integer(0);
		 private Integer IdCicmRa=new Integer(0);
		//list  country,state,city for  delivery
	     private Set<Etat> listeEtatcmRa;
		 private Set<Ville> listeVillecmRa;
		// identifiant de la gare du train
		  private Integer IdDRail=new Integer(0);
		  private List<Station> listeGareD=new ArrayList<Station>();
		  
		//date fin
	   private Date DatefinRa;
		//date début
		private Date dateDebutRa;
		
		//category
		private Integer IdCategoryRa=new Integer(0);
		private boolean urgentRa;
		
		
		
		
//for sea
		//type de transport
		 private String typeS;
	//pickup
		//country,state,city 
		  private Integer IdSSe=new Integer(0);
		  private Integer IdCSe=new Integer(0);
		  private Integer IdCiSe=new Integer(0);	
		//list  country,state,city for pickup
		  private Set<Etat> listeEtatSe;
		  private Set<Ville> listeVilleSe;
		// identifiant du port
			 private Integer IdPSea=new Integer(0); 
			 private List<Station> listePortP=new ArrayList<Station>();
		  
		//delivery
	     private Integer IdScmSe=new Integer(0);
		 private Integer IdCcmSe=new Integer(0);
		 private Integer IdCicmSe=new Integer(0);
		//list  country,state,city for  delivery
	     private Set<Etat> listeEtatcmSe;
		 private Set<Ville> listeVillecmSe;
		// identifiant du port
		 private Integer IdDSea=new Integer(0); 
		 private List<Station> listePortD=new ArrayList<Station>();
		  
		//date fin
	   private Date DatefinSe;
		//date début
		private Date dateDebutSe;
		
		//category
		private Integer IdCategorySe=new Integer(0);
		private boolean urgentSe;
		
//for air
		//type de transport
		 private String typeAi;
		//pickup
		//country,state,city 
		  private Integer IdSAi=new Integer(0);
		  private Integer IdCAi=new Integer(0);
		  private Integer IdCiAi=new Integer(0);	
		//list  country,state,city for pickup
		  private Set<Etat> listeEtatAi;
		  private Set<Ville> listeVilleAi;
		// identifiant de l'airport
			 private Integer IdPAirPort=new Integer(0); 
			 private List<Station> ListeAirP=new ArrayList<Station>();
		  
		//delivery
	     private Integer IdScmAi=new Integer(0);
		 private Integer IdCcmAi=new Integer(0);
		 private Integer IdCicmAi=new Integer(0);
		//list  country,state,city for  delivery
	     private Set<Etat> listeEtatcmAi;
		 private Set<Ville> listeVillecmAi;
		// identifiant de l'airport
		 private Integer IdDAirPort=new Integer(0);
		 private List<Station> ListeAiD=new ArrayList<Station>();
		  
		//date fin
	   private Date DatefinAi;
		//date début
		private Date dateDebutAi;
		
		//category
		private Integer IdCategoryAi=new Integer(0);
		private boolean urgentAi;
		
		
		
		
		

		public List<Station> getListeGareP() {
			return listeGareP;
		}


		public void setListeGareP(List<Station> listeGareP) {
			this.listeGareP = listeGareP;
		}


		public List<Station> getListeGareD() {
			return listeGareD;
		}


		public void setListeGareD(List<Station> listeGareD) {
			this.listeGareD = listeGareD;
		}


		public List<Station> getListePortP() {
			return listePortP;
		}


		public void setListePortP(List<Station> listePortP) {
			this.listePortP = listePortP;
		}


		public List<Station> getListePortD() {
			return listePortD;
		}


		public void setListePortD(List<Station> listePortD) {
			this.listePortD = listePortD;
		}


		public List<Station> getListeAirP() {
			return ListeAirP;
		}


		public void setListeAirP(List<Station> listeAirP) {
			ListeAirP = listeAirP;
		}


		public List<Station> getListeAiD() {
			return ListeAiD;
		}


		public void setListeAiD(List<Station> listeAiD) {
			ListeAiD = listeAiD;
		}


		public boolean getRedredPSea() {
			System.out.println(redredPSea);
			return redredPSea;
		}


		public void setRedredPSea(boolean redredPSea) {
			this.redredPSea = redredPSea;
		}


		public boolean getRedredDSea() {
			return redredDSea;
		}


		public void setRedredDSea(boolean redredDSea) {
			this.redredDSea = redredDSea;
		}


		public boolean getRedredSPSea() {
			return redredSPSea;
		}


		public void setRedredSPSea(boolean redredSPSea) {
			this.redredSPSea = redredSPSea;
		}


		public boolean getRedredSDSea() {
			return redredSDSea;
		}


		public void setRedredSDSea(boolean redredSDSea) {
			this.redredSDSea = redredSDSea;
		}


		public boolean getRedredPAir() {
			return redredPAir;
		}


		public void setRedredPAir(boolean redredPAir) {
			this.redredPAir = redredPAir;
		}


		public boolean getRedredDAir() {
			return redredDAir;
		}


		public void setRedredDAir(boolean redredDAir) {
			this.redredDAir = redredDAir;
		}


		public boolean getRedredSPAir() {
			return redredSPAir;
		}


		public void setRedredSPAir(boolean redredSPAir) {
			this.redredSPAir = redredSPAir;
		}


		public boolean getRedredSDAir() {
			return redredSDAir;
		}


		public void setRedredSDAir(boolean redredSDAir) {
			this.redredSDAir = redredSDAir;
		}


		public boolean getRedredPRail() {
			return redredPRail;
		}


		public void setRedredPRail(boolean redredPRail) {
			this.redredPRail = redredPRail;
		}


		public boolean getRedredDRail() {
			
			return redredDRail;
		}


		public void setRedredDRail(boolean redredDRail) {
			this.redredDRail = redredDRail;
		}


		public boolean getRedredSPRail() {
			return redredSPRail;
		}


		public void setRedredSPRail(boolean redredSPRail) {
			this.redredSPRail = redredSPRail;
		}


		public boolean getRedredSDRail() {
			return redredSDRail;
		}


		public void setRedredSDRail(boolean redredSDRail) {
			this.redredSDRail = redredSDRail;
		}


		public String getTypeR() {
			return typeR;
		}


		public void setTypeR(String typeR) {
			this.typeR = typeR;
		}


		public String getTypeS() {
			return typeS;
		}


		public void setTypeS(String typeS) {
			this.typeS = typeS;
		}


		public String getTypeAi() {
			return typeAi;
		}


		public void setTypeAi(String typeAi) {
			this.typeAi = typeAi;
		}


		public Integer getIdSRa() {
			return IdSRa;
		}


		public void setIdSRa(Integer idSRa) {
			IdSRa = idSRa;
		}


		public Integer getIdCRa() {
			return IdCRa;
		}


		public void setIdCRa(Integer idCRa) {
			IdCRa = idCRa;
		}


		public Integer getIdCiRa() {
			return IdCiRa;
		}


		public void setIdCiRa(Integer idCiRa) {
			IdCiRa = idCiRa;
		}


		public Set<Etat> getListeEtatRa() {
			return listeEtatRa;
		}


		public void setListeEtatRa(Set<Etat> listeEtatRa) {
			this.listeEtatRa = listeEtatRa;
		}


		public Set<Ville> getListeVilleRa() {
			return listeVilleRa;
		}


		public void setListeVilleRa(Set<Ville> listeVilleRa) {
			this.listeVilleRa = listeVilleRa;
		}


		public Integer getIdScmRa() {
			return IdScmRa;
		}


		public void setIdScmRa(Integer idScmRa) {
			IdScmRa = idScmRa;
		}


		public Integer getIdCcmRa() {
			return IdCcmRa;
		}


		public void setIdCcmRa(Integer idCcmRa) {
			IdCcmRa = idCcmRa;
		}


		public Integer getIdCicmRa() {
			return IdCicmRa;
		}


		public void setIdCicmRa(Integer idCicmRa) {
			IdCicmRa = idCicmRa;
		}


		public Set<Etat> getListeEtatcmRa() {
			return listeEtatcmRa;
		}


		public void setListeEtatcmRa(Set<Etat> listeEtatcmRa) {
			this.listeEtatcmRa = listeEtatcmRa;
		}


		public Set<Ville> getListeVillecmRa() {
			return listeVillecmRa;
		}


		public void setListeVillecmRa(Set<Ville> listeVillecmRa) {
			this.listeVillecmRa = listeVillecmRa;
		}


		public Date getDatefinRa() {
			return DatefinRa;
		}


		public void setDatefinRa(Date datefinRa) {
			DatefinRa = datefinRa;
		}


		public Date getDateDebutRa() {
			return dateDebutRa;
		}


		public void setDateDebutRa(Date dateDebutRa) {
			this.dateDebutRa = dateDebutRa;
		}


		public Integer getIdCategoryRa() {
			return IdCategoryRa;
		}


		public void setIdCategoryRa(Integer idCategoryRa) {
			IdCategoryRa = idCategoryRa;
		}


		public boolean getUrgentRa() {
			return urgentRa;
		}


		public void setUrgentRa(boolean urgentRa) {
			this.urgentRa = urgentRa;
		}


		public Integer getIdSSe() {
			return IdSSe;
		}


		public void setIdSSe(Integer idSSe) {
			IdSSe = idSSe;
		}


		public Integer getIdCSe() {
			return IdCSe;
		}


		public void setIdCSe(Integer idCSe) {
			IdCSe = idCSe;
		}


		public Integer getIdCiSe() {
			return IdCiSe;
		}


		public void setIdCiSe(Integer idCiSe) {
			IdCiSe = idCiSe;
		}


		public Set<Etat> getListeEtatSe() {
			return listeEtatSe;
		}


		public void setListeEtatSe(Set<Etat> listeEtatSe) {
			this.listeEtatSe = listeEtatSe;
		}


		public Set<Ville> getListeVilleSe() {
			return listeVilleSe;
		}


		public void setListeVilleSe(Set<Ville> listeVilleSe) {
			this.listeVilleSe = listeVilleSe;
		}


		public Integer getIdScmSe() {
			return IdScmSe;
		}


		public void setIdScmSe(Integer idScmSe) {
			IdScmSe = idScmSe;
		}


		public Integer getIdCcmSe() {
			return IdCcmSe;
		}


		public void setIdCcmSe(Integer idCcmSe) {
			IdCcmSe = idCcmSe;
		}


		public Integer getIdCicmSe() {
			return IdCicmSe;
		}


		public void setIdCicmSe(Integer idCicmSe) {
			IdCicmSe = idCicmSe;
		}


		public Set<Etat> getListeEtatcmSe() {
			return listeEtatcmSe;
		}


		public void setListeEtatcmSe(Set<Etat> listeEtatcmSe) {
			this.listeEtatcmSe = listeEtatcmSe;
		}


		public Set<Ville> getListeVillecmSe() {
			return listeVillecmSe;
		}


		public void setListeVillecmSe(Set<Ville> listeVillecmSe) {
			this.listeVillecmSe = listeVillecmSe;
		}


		public Date getDatefinSe() {
			return DatefinSe;
		}


		public void setDatefinSe(Date datefinSe) {
			DatefinSe = datefinSe;
		}


		public Date getDateDebutSe() {
			return dateDebutSe;
		}


		public void setDateDebutSe(Date dateDebutSe) {
			this.dateDebutSe = dateDebutSe;
		}


		public Integer getIdCategorySe() {
			return IdCategorySe;
		}


		public void setIdCategorySe(Integer idCategorySe) {
			IdCategorySe = idCategorySe;
		}


		public boolean isUrgentSe() {
			return urgentSe;
		}


		public void setUrgentSe(boolean urgentSe) {
			this.urgentSe = urgentSe;
		}


		public Integer getIdSAi() {
			return IdSAi;
		}


		public void setIdSAi(Integer idSAi) {
			IdSAi = idSAi;
		}


		public Integer getIdCAi() {
			return IdCAi;
		}


		public void setIdCAi(Integer idCAi) {
			IdCAi = idCAi;
		}


		public Integer getIdCiAi() {
			return IdCiAi;
		}


		public void setIdCiAi(Integer idCiAi) {
			IdCiAi = idCiAi;
		}


		public Set<Etat> getListeEtatAi() {
			return listeEtatAi;
		}


		public void setListeEtatAi(Set<Etat> listeEtatAi) {
			this.listeEtatAi = listeEtatAi;
		}


		public Set<Ville> getListeVilleAi() {
			return listeVilleAi;
		}


		public void setListeVilleAi(Set<Ville> listeVilleAi) {
			this.listeVilleAi = listeVilleAi;
		}


		public Integer getIdScmAi() {
			return IdScmAi;
		}


		public void setIdScmAi(Integer idScmAi) {
			IdScmAi = idScmAi;
		}


		public Integer getIdCcmAi() {
			return IdCcmAi;
		}


		public void setIdCcmAi(Integer idCcmAi) {
			IdCcmAi = idCcmAi;
		}


		public Integer getIdCicmAi() {
			return IdCicmAi;
		}


		public void setIdCicmAi(Integer idCicmAi) {
			IdCicmAi = idCicmAi;
		}


		public Set<Etat> getListeEtatcmAi() {
			return listeEtatcmAi;
		}


		public void setListeEtatcmAi(Set<Etat> listeEtatcmAi) {
			this.listeEtatcmAi = listeEtatcmAi;
		}


		public Set<Ville> getListeVillecmAi() {
			return listeVillecmAi;
		}


		public void setListeVillecmAi(Set<Ville> listeVillecmAi) {
			this.listeVillecmAi = listeVillecmAi;
		}


		public Date getDatefinAi() {
			return DatefinAi;
		}


		public void setDatefinAi(Date datefinAi) {
			DatefinAi = datefinAi;
		}


		public Date getDateDebutAi() {
			return dateDebutAi;
		}


		public void setDateDebutAi(Date dateDebutAi) {
			this.dateDebutAi = dateDebutAi;
		}


		public Integer getIdCategoryAi() {
			return IdCategoryAi;
		}


		public void setIdCategoryAi(Integer idCategoryAi) {
			IdCategoryAi = idCategoryAi;
		}


		public boolean isUrgentAi() {
			return urgentAi;
		}


		public void setUrgentAi(boolean urgentAi) {
			this.urgentAi = urgentAi;
		}


		public Integer getIdCategory() {
			return IdCategory;
		}


		public void setIdCategory(Integer idCategory) {
			IdCategory = idCategory;
		}


		public boolean isUrgent() {
			return urgent;
		}


		public void setUrgent(boolean urgent) {
			this.urgent = urgent;
		}


		public Date getDatefin() {
			
			return Datefin;
		}


		public void setDatefin(Date datefin) {
			System.out.println("set"+Datefin);
			Datefin = datefin;
		}


		public Date getDateDebut() {
			return dateDebut;
		}


		public void setDateDebut(Date dateDebut) {
			this.dateDebut = dateDebut;
		}


	


		public  Set<Etat> getListeEtatcm() {
			return listeEtatcm;
		}


		public  void setListeEtatcm(Set<Etat> listeEtatcm) {
			this.listeEtatcm = listeEtatcm;
		}


		public  Set<Ville> getListeVillecm() {
			return listeVillecm;
		}


		public  void setListeVillecm(Set<Ville> listeVillecm) {
			this.listeVillecm = listeVillecm;
		}


		public  Integer getIdScm() {
			return IdScm;
		}


		public  void setIdScm(Integer idScm) {
			IdScm = idScm;
		}


		public  Integer getIdCcm() {
			return IdCcm;
		}


		public  void setIdCcm(Integer idCcm) {
			IdCcm = idCcm;
		}


		public  Integer getIdCicm() {
			return IdCicm;
		}


		public  void setIdCicm(Integer idCicm) {
			IdCicm = idCicm;
		}


		public  Integer getIdS() {
			return IdS;
		}


		public  void setIdS(Integer idS) {
			IdS = idS;
		}


		public  Integer getIdC() {
			return IdC;
		}


		public  void setIdC(Integer idC) {
		
			IdC = idC;
		}


		public  Integer getIdCi() {
			return IdCi;
		}


		public  void setIdCi(Integer idCi) {
			IdCi = idCi;
		}


		public  Set<Etat> getListeEtat() {
			return listeEtat;
		}


	


		public  Set<Ville> getListeVille() {
			return listeVille;
		}


		public  void setListeVille(Set<Ville> listeVille) {
			this.listeVille = listeVille;
		}


		public Integer getIdPRail() {
			return IdPRail;
		}


		public void setIdPRail(Integer idPRail) {
			IdPRail = idPRail;
		}


		public Integer getIdDRail() {
			return IdDRail;
		}


		public void setIdDRail(Integer idDRail) {
			IdDRail = idDRail;
		}


		public Integer getIdPSea() {
			return IdPSea;
		}


		public void setIdPSea(Integer idPSea) {
			IdPSea = idPSea;
		}


		public Integer getIdDSea() {
			return IdDSea;
		}


		public void setIdDSea(Integer idDSea) {
			IdDSea = idDSea;
		}


		public Integer getIdPAirPort() {
			return IdPAirPort;
		}


		public void setIdPAirPort(Integer idPAirPort) {
			IdPAirPort = idPAirPort;
		}


		public Integer getIdDAirPort() {
			return IdDAirPort;
		}


		public void setIdDAirPort(Integer idDAirPort) {
			IdDAirPort = idDAirPort;
		}


		public  void setListeEtat(Set<Etat> listeEtat) {
			this.listeEtat = listeEtat;
		}


		
		@PostConstruct
		public void init()
		{
			archive();
			DeclarationGagner();
			
		}
		
		
		
		
		
		
		
		////////////////////
		public List<Pays> getListPays()
		{
			 
			return meteirp.getAllPaysActive();
		}
		
		
		
		
		public void onCountryChange(Long i) {
			
		
			 
			 if(i==0)
			 {
				 if(IdC!=0)
			        {
			        	
					 listeEtat= meteirp.getPays(IdC).getListEtat();
			        }
			        else
			        {
			        	
			        	listeEtat=null;
			        	listeVille=null;
			        	IdS=new Integer(0);
			        	IdCi=new Integer(0);
			        	
			        }
			 }
			 
			 if(i==1)
			 {
				 
				 if(IdCcm!=0)
			        {
			        	
					
					 listeEtatcm= meteirp.getPays(IdCcm).getListEtat();
			        	
			        }
			        else
			        {
			        	listeEtatcm=null;
			        	listeVillecm=null;
			        	IdScm=new Integer(0);
			        	IdCicm=new Integer(0);
			        }
			 }
			 //pays pour le type by rail
			 if(i==2)
			 {
				 if(IdCRa!=0)
			        {
				
					 if(typeR.compareTo("StationToDoor")==0 || typeR.compareTo("StationToStation")==0)
					 {
						 listeGareP=metierStation.getAllActiveStationLocation(0,0,IdCRa);
						 System.out.println("listeGareP"+listeGareP.size());
					 }
			        	
					 listeEtatRa= meteirp.getPays(IdCRa).getListEtat();
			        }
			        else
			        {
			        	listeEtatRa=null;
			        	listeVilleRa=null;
			        	IdSRa=new Integer(0);
			        	IdCiRa=new Integer(0);
			        	
			        	listeGareP=metierStation.getAllActiveStation(0);
			        }
			 }
			 
			 if(i==3)
			 {
				 if(IdCcmRa!=0)
			        {
					 
					 if(typeR.compareTo("DoorToStation")==0 || typeR.compareTo("StationToStation")==0)
					 {
						 listeGareD=metierStation.getAllActiveStationLocation(0,0,IdCcmRa);
					 }
			        	
					 listeEtatcmRa= meteirp.getPays(IdCcmRa).getListEtat();
			        	
			        }
			        else
			        {
			        	listeGareD=metierStation.getAllActiveStation(0);
			        	listeEtatcmRa=null;
			        	listeVillecmRa=null;
			        	IdScmRa=new Integer(0);
			        	IdCicmRa=new Integer(0);
			        	
			        }
			 }
			 //by sea
			 if(i==4)
			 {
				 if(IdCSe!=0)
			        {
					 
					 if(typeS.compareTo("PortToDoor")==0 || typeS.compareTo("PortToPort")==0)
					 {
						 listePortP=metierStation.getAllActiveStationLocation(1,0,IdCSe);
					 }
			        	
					 listeEtatSe= meteirp.getPays(IdCSe).getListEtat();
			        }
			        else
			        {
			        	listePortP=metierStation.getAllActiveStation(1);
			        	listeEtatSe=null;
			        	listeVilleSe=null;
			        	IdSSe=new Integer(0);
			        	IdCiSe=new Integer(0);
			        }
			 }
			 
			 if(i==5)
			 {
				 if(IdCcmSe!=0)
			        {
					 if(typeS.compareTo("DoorToPort")==0 || typeS.compareTo("PortToPort")==0)
					 {
						 listePortD=metierStation.getAllActiveStationLocation(1,0,IdCcmSe);
					 }
			        	
					 listeEtatcmSe= meteirp.getPays(IdCcmSe).getListEtat();
			        	
			        }
			        else
			        {
			        	listePortD=metierStation.getAllActiveStation(1);
			        	listeEtatcmSe=null;
			        	listeVillecmSe=null;
			        	IdScmSe=new Integer(0);
			        	IdCicmSe=new Integer(0);
			        }
			 }
			 
			 //by air
			 if(i==6)
			 {
				 
				 if(IdCAi!=0)
			        {
					 
					 if(typeAi.compareTo("AirPortToDoor")==0 || typeAi.compareTo("AirPortToAirPort")==0)
					 {
						 ListeAirP=metierStation.getAllActiveStationLocation(2,0,IdCAi);
					 }
			        	
					 listeEtatAi= meteirp.getPays(IdCAi).getListEtat();
			        }
			        else
			        {
			        	ListeAirP=metierStation.getAllActiveStation(2);
			        	listeEtatAi=null;
			        	listeVilleAi=null;
			        	IdSAi=new Integer(0);
			        	IdCiAi=new Integer(0);
			        }
			 }
			 
			 if(i==7)
			 {
				 if(IdCcmAi!=0)
			        {
					 
					 //si le type de transport n'est pas de type DoorToDoor
					 if(typeAi.compareTo("DoorToAirPort")==0 || typeAi.compareTo("AirPortToAirPort")==0)
					 {
						 ListeAiD=metierStation.getAllActiveStationLocation(2,0,IdCcmAi);
					 }
			        	
					 listeEtatcmAi= meteirp.getPays(IdCcmAi).getListEtat();
			        	
			        }
			        else
			        {
			        	ListeAiD=metierStation.getAllActiveStation(2);
			        	listeEtatcmAi=null;
			        	listeVillecmAi=null;
			        	IdScmAi=new Integer(0);
			        	IdCicmAi=new Integer(0);
			        }
			 }
			    
		    }
		 
		 public void onStateChange(Long i) {
			
			 //by road
			 if(i==0)
			 {
				 if(IdS!=0)
			        {
			        	
			        	listeVille=metiere.getEtat(IdS).getListVille();
			        }
			        else
			        {
			        	listeVille=null;
			        	IdCi=new Integer(0);
			        }
			 }
			 
			 if(i==1)
			 {
				 if(IdScm!=0)
			        {
			        	
			        	listeVillecm=metiere.getEtat(IdScm).getListVille();
			        }
			        else
			        {
			        	listeVillecm=null;
			        	IdCicm=new Integer(0);
			        }
			 }
			//by rail
			 if(i==2)
			 {
				 if(IdSRa!=0)
			        {
					 
					 if(typeR.compareTo("StationToDoor")==0 || typeR.compareTo("StationToStation")==0)
					 {
						 
						 listeGareP=metierStation.getAllActiveStationLocation(0, 1, IdSRa);
						 
					 }
			        	
			        	listeVilleRa=metiere.getEtat(IdSRa).getListVille();
			        }
			        else
			        {
			        	 if(typeR.compareTo("StationToDoor")==0 || typeR.compareTo("StationToStation")==0)
						 {
			        		 
			        		 if(IdCRa!=0)
			        		 {
			        			 listeGareP=metierStation.getAllActiveStationLocation(0, 0, IdCRa);
			        		 }
			        		 else
			        		 {
			        		 listeGareP=metierStation.getAllActiveStation(0);
			        		 }
			        		 
						 }
			        	listeVilleRa=null;
			        	IdCiRa=new Integer(0);
			        }
			 }
			 
			 if(i==3)
			 {
				 if(IdScmRa!=0)
			        {
					 
					 if(typeR.compareTo("DoorToStation")==0 || typeR.compareTo("StationToStation")==0)
					 {
						 listeGareD=metierStation.getAllActiveStationLocation(0, 1, IdScmRa);
					 }
					 
			        	listeVillecmRa=metiere.getEtat(IdScmRa).getListVille();
			        }
			        else
			        {
			        	if(typeR.compareTo("DoorToStation")==0 || typeR.compareTo("StationToStation")==0)
						 {
			        		if(IdCcmRa!=0)
			        		{
			        			 listeGareD=metierStation.getAllActiveStationLocation(0, 0, IdCcmRa);
			        		}
			        		else
			        		{
			        			listeGareD=metierStation.getAllActiveStation(0);
			        		}
						 }
			        	listeVillecmRa=null;
			        	IdCcmRa=new Integer(0);
			        }
			 }
			 //by sea
			 if(i==4)
			 {
				 if(IdSSe!=0)
			        {
					 if(typeS.compareTo("PortToDoor")==0 || typeS.compareTo("PortToPort")==0)
					 {
						 listePortP=metierStation.getAllActiveStationLocation(1, 1, IdSSe);
					 }
			        	
			        	listeVilleSe=metiere.getEtat(IdSSe).getListVille();
			        }
			        else
			        {
			        	 if(typeS.compareTo("PortToDoor")==0 || typeS.compareTo("PortToPort")==0)
						 {
			        		 if(IdCSe!=0)
			        		 {
			        			 listePortP=metierStation.getAllActiveStationLocation(1, 0, IdCSe);
			        		 }
			        		 else
			        		 {
			        			 listePortP=metierStation.getAllActiveStation(1);
			        		 }
						 }
			        	listeVilleSe=null;
			        }
			 }
			 
			 if(i==5)
			 {
				 if(IdScmSe!=0)
			        {
					 if(typeS.compareTo("DoorToPort")==0 || typeS.compareTo("PortToPort")==0)
					 {
						 listePortD=metierStation.getAllActiveStationLocation(1, 1, IdScmSe);
					 }
			        	listeVillecmSe=metiere.getEtat(IdScmSe).getListVille();
			        }
			        else
			        {
			        	 if(typeS.compareTo("DoorToPort")==0 || typeS.compareTo("PortToPort")==0)
						 {
			        		 
			        		 if(IdCcmSe!=0)
			        		 {
			        			 listePortD=metierStation.getAllActiveStationLocation(1, 0, IdCcmSe);
			        		 }
			        		 else
			        		 {
			        	       listePortD=metierStation.getAllActiveStation(1);
			        		 }
			        	
						 }
			        	listeVillecmSe=null;
			        	IdCcmSe=new Integer(0);
			        }
			 }
			 //by air
			 if(i==6)
			 {
				 if(IdSAi!=0)
			        {
					 if(typeAi.compareTo("AirPortToDoor")==0 || typeAi.compareTo("AirPortToAirPort")==0)
					 {
						 ListeAirP=metierStation.getAllActiveStationLocation(2, 1, IdSAi);
					 }
			        	
			        	listeVilleAi=metiere.getEtat(IdSAi).getListVille();
			        }
			        else
			        {
			        	if(typeAi.compareTo("AirPortToDoor")==0 || typeAi.compareTo("AirPortToAirPort")==0)
						 {
			        		if(IdCAi!=0)
			        		{
			        			ListeAirP=metierStation.getAllActiveStationLocation(2, 0, IdCAi);
			        		}
			        		else
			        		{
			        			ListeAirP=metierStation.getAllActiveStation(2);
			        		}
						 }
			        	listeVilleAi=null;
			        	IdCAi=new Integer(0);
			        }
			 }
			 
			 if(i==7)
			 {
				 if(IdScmAi!=0)
			        {
					 if(typeAi.compareTo("DoorToAirPort")==0 || typeAi.compareTo("AirPortToAirPort")==0)
					 {
						
						 ListeAiD=metierStation.getAllActiveStationLocation(2,1,IdScmAi);
						 
					 }
			        	
			        	listeVillecmAi=metiere.getEtat(IdScmAi).getListVille();
			        }
			        else
			        {
			        	if(typeAi.compareTo("DoorToAirPort")==0 || typeAi.compareTo("AirPortToAirPort")==0)
						 {
			        		if(IdCcmAi!=0)
			        		{
			        			ListeAiD=metierStation.getAllActiveStationLocation(2, 0, IdCcmAi);
			        		}
			        		else
			        		{
			        			ListeAiD=metierStation.getAllActiveStation(2);
			        		}
						 }
			        	listeVillecmAi=null;
			        	IdCicmAi=new Integer(0);
			        }
			 }
			 
			 
			   
		    }
		 
		 //lorsqu'on choisis une ville
		 public void onchangeCity(Long i)
		 {
			 
			 if(i==0)
			 {
				 
				 //tester la ville de départ
				 if(IdCiRa!=0)
				 {
					 if(typeR.compareTo("StationToDoor")==0 || typeR.compareTo("StationToStation")==0)
					 {
						 
						 listeGareP=metierStation.getAllActiveStationLocation(0,2, IdCiRa);
					 }
				 }
				 else
				 {
					 if(typeR.compareTo("StationToDoor")==0 || typeR.compareTo("StationToStation")==0)
					 {
					 //tester si l'état est vide
					 if(IdSRa!=0)
					 {
						 listeGareP=metierStation.getAllActiveStationLocation(0,1, IdSRa);
					 }
					 //tester si le pays est vide
					 else if(IdCRa!=0)
					 {
						 listeGareP=metierStation.getAllActiveStationLocation(0,0, IdCRa);
					 }
					 else
					 {
						 listeGareP=metierStation.getAllActiveStation(0);
					 }
					 }
				 }
				 
				
				//tester la ville d'arrivée
				 if(IdCicmRa!=0)
				 {
				 
		            if(typeR.compareTo("DoorToStation")==0 || typeR.compareTo("StationToStation")==0)
					 {
		            	listeGareD=metierStation.getAllActiveStationLocation(0,2, IdCicmRa);
					 }
		         
		            
		            
				 }
			
				 else
		          {
					   if(typeR.compareTo("DoorToStation")==0 || typeR.compareTo("StationToStation")==0)
						 {
				            	if(IdScmRa!=0)
				            	{
				            		System.out.println("helloooo");
				            		listeGareD=metierStation.getAllActiveStationLocation(0,1, IdScmRa);
				            	}
				            	else if(IdCcmRa!=0)
				            	{
				            		listeGareD=metierStation.getAllActiveStationLocation(0,0, IdCcmRa);
				            	}
				            	else
				            	{
				            		listeGareD=metierStation.getAllActiveStation(0);
				            	}
						 }
		            	
		          }
			 }
			 
			 if(i==1)
			 {
				 
					 if(IdCiSe!=0)
					 {
			            if(typeS.compareTo("PortToDoor")==0 || typeS.compareTo("PortToPort")==0)
						 {
			            	listePortP=metierStation.getAllActiveStationLocation(1,2, IdCiSe);
						 }
					 }
					 else
					 {
						 if(typeS.compareTo("PortToDoor")==0 || typeS.compareTo("PortToPort")==0)
						 {
							 if(IdSSe!=0)
							 {
								 listePortP=metierStation.getAllActiveStationLocation(1,1, IdSSe);
							 }
							 else if(IdCSe!=0)
							 {
								 listePortP=metierStation.getAllActiveStationLocation(1,0, IdCSe);
							 }
							 else
							 {
								 listePortP=metierStation.getAllActiveStation(1);
							 }
						 }
						 
					 }
					 
					 if(IdCicmSe!=0)
					 {
			            if(typeS.compareTo("DoorToPort")==0 || typeS.compareTo("PortToPort")==0)
						 {
			            	listePortD=metierStation.getAllActiveStationLocation(1,2, IdCicmSe);
						 }
					 }
					 else
					 {
				            if(typeS.compareTo("DoorToPort")==0 || typeS.compareTo("PortToPort")==0)
							 {
				            	if(IdScmSe!=0)
				            	{
				            		listePortD=metierStation.getAllActiveStationLocation(1,1, IdScmSe);
				            	}
				            	else if(IdCcmSe!=0)
				            	{
				            		listePortD=metierStation.getAllActiveStationLocation(1,0, IdCcmSe);
				            	}
				            	else
				            	{
				            		listePortD=metierStation.getAllActiveStation(1);
				            	}
				            	
							 }
					 }
					 
			 }
			 
			 if(i==2)
			 {
			 if(IdCiAi!=0)
			 {
				 if(typeAi.compareTo("AirPortToDoor")==0 || typeAi.compareTo("AirPortToAirPort")==0)
				 {
					 ListeAirP=metierStation.getAllActiveStationLocation(2,2, IdCiAi);
				 }
				 
			 }
			 else
			 {
				 if(typeAi.compareTo("AirPortToDoor")==0 || typeAi.compareTo("AirPortToAirPort")==0)
				 {
					 if(IdSAi!=0)
					 {
						 ListeAirP=metierStation.getAllActiveStationLocation(2,1, IdSAi);
					 }
					 else if(IdCAi!=0)
					 {
						 ListeAirP=metierStation.getAllActiveStationLocation(2,0, IdCAi);
					 }
					 else
					 {
						 ListeAirP=metierStation.getAllActiveStation(2);
					 }
				 }
				 
			 }
			 
			 //si le type de transport n'est pas de type DoorToDoor
			 if(IdCicmAi!=0)
			 {
				 if(typeAi.compareTo("DoorToAirPort")==0 || typeAi.compareTo("AirPortToAirPort")==0)
				 {
					 ListeAiD=metierStation.getAllActiveStationLocation(2,2, IdCicmAi);
				 }
			 }
			 else
			 {
				   if(IdScmAi!=0)
				   {
					   ListeAiD=metierStation.getAllActiveStationLocation(2,1, IdScmAi);
				   }
				   else if(IdCcmAi!=0)
				   {
					   ListeAiD=metierStation.getAllActiveStationLocation(2,0, IdCcmAi);
				   }
				   else
				   {
					   ListeAiD=metierStation.getAllActiveStation(2);
				   }
					   
			 }
			 
			 
			 }
		 }
		 
		 //liste des catégorie
		 public List<SubCategorie> listeSubCategory()
		 {
		
			 return metiersub.getAllSubCategories();
		 }
		 
		
		 
		 //liste des offres
		 public List<Offre> listeoffres(Integer i)
		 {
			 
			 
		     List<Offre> liste=new ArrayList<Offre>();
		     List<Offre> listeOffre=metier.getOffreForSearch(i);
		     System.out.println(i+"init"+listeOffre.size());
		     
		     for(int j=0;j<listeOffre.size();j++)
		     {
		    	 //pickup 
		    	 boolean pkcountry=true;
		    	 boolean pkstate=true;
		    	 boolean pkcity=true;
		    	//delivery 
		    	 boolean dlcountry=true;
		    	 boolean dlstate=true;
		    	 boolean dlcity=true;
		    	 //date 
		    	 //from
		    	 boolean datefrom=true;
		    	 //till
		    	 boolean datetill=true;
		    	 
		    	 boolean urgence=true;
		    	 boolean category=true;
		    	 
		    	 //station depart 
		         boolean stationDepart=true;
		     
		    	 //station d'arrivée
		         boolean stationArrivee = true;
		    	 
		     if(i==0)
		     {
		    	 
		    	 //pickup
		    	 //test pickup country
		    	 
		    	 if(IdC!=0)
		    	 {
		    		 
		    		 if(listeOffre.get(j).getVilleDepart().getEtat().getPays().getIdPays()==IdC)
		    		 {
		    			 pkcountry=true;
		    		 }
		    		 else
		    		 {
		    			 pkcountry=false;
		    		 }
		    		 
		    	 }
		    	 
		    	 //test pickup state
		    	 
		    	 if(IdS!=0)
		    	 {
		    		 if(listeOffre.get(j).getVilleDepart().getEtat().getIdEtat()==IdS)
		    		 {
		    			 pkstate=true;
		    		 }
		    		 else
		    		 {
		    			 pkstate=false;
		    		 }
		    	 }
		    	 
		    	 //test pickup city
		    	 if(IdCi!=0)
		    	 {
		    		 if(listeOffre.get(j).getVilleDepart().getIdVille()==IdCi)
		    		 {
		    			 pkcity=true;
		    		 }
		    		 else
		    		 {
		    			 pkcity=false;
		    		 }
		    	 }
		    	 
		    	//delivery
		    	 //test delivery country
		    	 if(IdCcm!=0)
		    	 {
		    		 if(listeOffre.get(j).getVilleArrive().getEtat().getPays().getIdPays()==IdCcm)
		    		 {
		    			 dlcountry=true;
		    		 }
		    		 else
		    		 {
		    			 dlcountry=false;
		    		 }
		    	 }
		    	 
		    	 //test delivery state
		    	 
		    	 if(IdScm!=0)
		    	 {
		    		 if(listeOffre.get(j).getVilleArrive().getEtat().getIdEtat()==IdScm)
		    		 {
		    			 dlstate=true;
		    		 }
		    		 else
		    		 {
		    			 dlstate=false;
		    		 }
		    	 }
		    	 
		    	 //test delivery city
		    	 if(IdCicm!=0)
		    	 {
		    		 if(listeOffre.get(j).getVilleArrive().getIdVille()==IdCicm)
		    		 {
		    			 dlcity=true;
		    		 }
		    		 else
		    		 {
		    			 dlcity=false;
		    		 }
		    	 }
		    	 //test sub category
		    	 if(IdCategory!=0)
		    	 {
		    		 if(listeOffre.get(j).getSubcategory().getIdSubCategorie()==IdCategory)
		    		 {
		    			 category=true;
		    		 }
		    		 else
		    		 {
		    			 category=false; 
		    		 }
		    	 }
		    	 //tester l'urgence
		    
		    	 if(listeOffre.get(j).getUrgent()==urgent)
		    	 {
		    		 
		    		 urgence=true;
		    	 }
		    	 else
		    	 {
		    		 urgence=false;
		    	 }
		    	 
		    	 //dates
		    	 if(dateDebut!=null)
		    	 {
		    		 if(listeOffre.get(j).getDate_Chargement().compareTo(dateDebut)>=0)
		    		 {
		    			 datefrom=true;
		    		 }
		    		 else
		    		 {
		    			 datefrom=false;
		    		 }
		    	 }
		    	
		    	 if(Datefin!=null)
		    	 {
		    		
		    		 if(listeOffre.get(j).getDate_Chargement().compareTo(Datefin)<=0)
		    		 {
		    			 datetill=true;
		    		 }
		    		 else
		    		 {
		    			 datetill=false;
		    		 }
		    		 
		    	 }
		    	 
		    	
		    	 
		     }
		     //les gares de train
		     else if(i==1)
		     {
		    	 
		    	 
		    	 //pickup
		    	 //test pickup country
		    	 if(IdCRa!=0)
		    	 {
		    		 if(typeR.compareTo("StationToDoor")==0 ||  typeR.compareTo("StationToStation")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Depart()!=null)
		    			 {
		    			 if(listeOffre.get(j).getStation_Depart().getVilleStations().getEtat().getPays().getIdPays()==IdCRa)
		    			 {
		    				 pkcountry=true;
		    			 }
		    			 else
		    			 {
		    				 pkcountry=false;
		    			 }
		    			 }
		    			 else
		    			 {
		    				 pkcountry=false;
		    			 }
		
		    		 }
		    			 
		    		 else
		    		 {
		    		 if(listeOffre.get(j).getVilleDepart().getEtat().getPays().getIdPays()==IdCRa)
		    		 {
		    			 pkcountry=true;
		    		 }
		    		 else
		    		 {
		    			 pkcountry=false;
		    		 }
		    		 }
		    	 }
		    	 
		    	 //test pickup state
		    	 
		    	 if(IdSRa!=0)
		    	 {
		    		 if(typeR.compareTo("StationToDoor")==0 ||  typeR.compareTo("StationToStation")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Depart()!=null)
		    			 {
			    			 if(listeOffre.get(j).getStation_Depart().getVilleStations().getEtat().getIdEtat()==IdSRa)
			    			 {
			    				 pkstate=true;
			    			 }
			    			 else
			    			 {
			    				 pkstate=false;
			    			 }
		    			 }
		    			 else
		    			 {
		    				 pkstate=false;
		    			 }
		
		    		 }
			    	 else
			    	 {
			    		 if(listeOffre.get(j).getVilleArrive().getEtat().getIdEtat()==IdSRa)
			    		 {
			    			 pkstate=true;
			    		 }
			    		 else
			    		 {
			    			 pkstate=false;
			    		 }
			    	 }
		    	 }
		    	 
		    	 //test pickup city
		    	 if(IdCiRa!=0)
		    	 {
		    		 if(typeR.compareTo("StationToDoor")==0 ||  typeR.compareTo("StationToStation")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Depart()!=null)
		    			 {
			    			 if(listeOffre.get(j).getStation_Depart().getVilleStations().getIdVille()==IdCiRa)
			    			 {
			    				 pkcity=true;
			    			 }
			    			 else
			    			 {
			    				 pkcity=false;
			    			 }
		    			 }
		    			 else
		    			 {
		    				 pkcity=false;
		    			 }
		
		    		 }
		    		 else
		    		 {
		    		 if(listeOffre.get(j).getVilleArrive().getIdVille()==IdCiRa)
		    		 {
		    			 pkcity=true;
		    		 }
		    		 else
		    		 {
		    			 pkcity=false;
		    		 }
		    		 }
		    	 }
		    	 
		    	//delivery
		    	 //test delivery country
		    	 if(IdCcmRa!=0)
		    	 {
		    		 if(typeR.compareTo("DoorToStation")==0 ||  typeR.compareTo("StationToStation")==0)
		    		 {
			    			 if(listeOffre.get(j).getStation_Arrive()!=null)
			    			 {
				    			 if(listeOffre.get(j).getStation_Arrive().getVilleStations().getEtat().getPays().getIdPays()==IdCcmRa)
				    			 {
				    				 dlcountry=true;
				    			 }
				    			 else
				    			 {
				    				 dlcountry=false;
				    			 }
			    			 }
			    			 else
			    			 {
			    				 dlcountry=false;
			    			 }
		
		    		 }
		    		 else
		    		 {
		    		 if(listeOffre.get(j).getVilleArrive().getEtat().getPays().getIdPays()==IdCcmRa)
		    		 {
		    			 dlcountry=true;
		    		 }
		    		 else
		    		 {
		    			 dlcountry=false;
		    		 }
		    		 }
		    	 }
		    	 
		    	 //test delivery state
		    	 
		    	 if(IdScmRa!=0)
		    	 {
		    		 if(typeR.compareTo("DoorToStation")==0 ||  typeR.compareTo("StationToStation")==0)
		    		 {
		    			 
		    			 if(listeOffre.get(j).getStation_Arrive()!=null)
		    			 {
		    			 if(listeOffre.get(j).getStation_Arrive().getVilleStations().getEtat().getIdEtat()==IdScmRa)
		    			 {
		    				 dlstate=true;
		    			 }
		    			 else
		    			 {
		    				 dlstate=false;
		    			 }
		    			 }
		    			 else
		    			 {
		    				 dlstate=false;
		    			 }
		
		    		 }
		    		 else
		    		 {
			    		 if(listeOffre.get(j).getVilleArrive().getEtat().getIdEtat()==IdScmRa)
			    		 {
			    			 dlstate=true;
			    		 }
			    		 else
			    		 {
			    			 dlstate=false;
			    		 }
		    		 }
		    	 }
		    	 
		    	 //test delivery city
		    	 if(IdCicmRa!=0)
		    	 {
		    		 
		    		 
		    		 if(typeR.compareTo("DoorToStation")==0 ||  typeR.compareTo("StationToStation")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Arrive()!=null)
		    			 {
		    			 if(listeOffre.get(j).getStation_Arrive().getVilleStations().getIdVille()==IdCicmRa)
		    			 {
		    				 dlcity=true;
		    			 }
		    			 else
		    			 {
		    				 dlcity=false;
		    			 }
		    			 }
		    			 else
		    			 {
		    				 dlcity=false;
		    			 }
		
		    		 }
		    		 else
		    		 {
			    		 if(listeOffre.get(j).getVilleArrive().getIdVille()==IdCicmRa)
			    		 {
			    			 dlcity=true;
			    		 }
			    		 else
			    		 {
			    			 dlcity=false;
			    		 }
		    		 }
		    	 }
		    	 //test sub category
		    	 if(IdCategoryRa!=0)
		    	 {
		    		 if(listeOffre.get(j).getSubcategory().getIdSubCategorie()==IdCategoryRa)
		    		 {
		    			 category=true;
		    		 }
		    		 else
		    		 {
		    			 category=false; 
		    		 }
		    	 }
		    	 //tester l'urgence
		    
		    	 if(listeOffre.get(j).getUrgent()==urgentRa)
		    	 {
		    		 
		    		 urgence=true;
		    	 }
		    	 else
		    	 {
		    		 urgence=false;
		    	 }
		    	 
		    	 //dates
		    	 if(dateDebutRa!=null)
		    	 {
		    		 if(listeOffre.get(j).getDate_Chargement().compareTo(dateDebutRa)>=0)
		    		 {
		    			 datefrom=true;
		    		 }
		    		 else
		    		 {
		    			 datefrom=false;
		    		 }
		    	 }
		    	
		    	 if(DatefinRa!=null)
		    	 {
		    		
		    		 if(listeOffre.get(j).getDate_Chargement().compareTo(DatefinRa)<=0)
		    		 {
		    			 datetill=true;
		    		 }
		    		 else
		    		 {
		    			 datetill=false;
		    		 }
		    		 
		    	 }
		    	
		    	 //tester les gares de train 
		    	 if(IdPRail!=0)
		    	 {
		    		 if(listeOffre.get(j).getStation_Arrive()!=null)
		    		 {
		    		 if(listeOffre.get(j).getStation_Arrive().getIdStation()==IdPRail)
		    		 {
		    			 
		    			 stationArrivee=true;
		    		 }
		    		 else
		    		 {
		    			 stationArrivee=false;
		    		 }
		    		 }
		    		 else
		    			 stationArrivee=false; 
		    	 }
		    	 
		    	//tester les gares de train 
		    	 if(IdDRail!=0)
		    	 {
		    		 if(listeOffre.get(j).getStation_Depart()!=null)
		    		 {
		    		 if(listeOffre.get(j).getStation_Depart().getIdStation()==IdDRail)
		    		 {
		    			 stationDepart=true;
		    		 }
		    		 else
		    		 {
		    			 stationDepart=false;
		    		 }
		    		 }
		    		 else
		    			 stationDepart=false; 
		    		 
		    	 }
		    	 
		    	
		    	 
		     }
		     //pour le type by sea
		     else if(i==2)
		     {
		    	 
		    	 
		    	 //pickup
		    	 //test pickup country
		    	 if(IdCSe!=0)
		    	 {
		    		 if(typeS.compareTo("PortToDoor")==0 ||  typeS.compareTo("PortToPort")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Depart()!=null)
		    			 {
		    			 if(listeOffre.get(j).getStation_Depart().getVilleStations().getEtat().getPays().getIdPays()==IdCSe)
		    			 {
		    				 pkcountry=true;
		    			 }
		    			 else
		    			 {
		    				 pkcountry=false;
		    			 }
		    			 }
		    			 else
		    			 {
		    				 pkcountry=false;
		    			 }
		
		    		 }
		    			 
		    		 else
		    		 {
		    		 if(listeOffre.get(j).getVilleDepart().getEtat().getPays().getIdPays()==IdCSe)
		    		 {
		    			 pkcountry=true;
		    		 }
		    		 else
		    		 {
		    			 pkcountry=false;
		    		 }
		    		 }
		    	 }
		    	 
		    	 //test pickup state
		    	 
		    	 if(IdSSe!=0)
		    	 {
		    		 if(typeS.compareTo("PortToDoor")==0 ||  typeS.compareTo("PortToPort")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Depart()!=null)
		    			 {
			    			 if(listeOffre.get(j).getStation_Depart().getVilleStations().getEtat().getIdEtat()==IdSSe)
			    			 {
			    				 pkstate=true;
			    			 }
			    			 else
			    			 {
			    				 pkstate=false;
			    			 }
		    			 }
		    			 else
		    			 {
		    				 pkstate=false;
		    			 }
		
		    		 }
			    	 else
			    	 {
			    		 if(listeOffre.get(j).getVilleArrive().getEtat().getIdEtat()==IdSSe)
			    		 {
			    			 pkstate=true;
			    		 }
			    		 else
			    		 {
			    			 pkstate=false;
			    		 }
			    	 }
		    	 }
		    	 
		    	 //test pickup city
		    	 if(IdCiSe!=0)
		    	 {
		    		 if(typeS.compareTo("PortToDoor")==0 ||  typeS.compareTo("PortToPort")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Depart()!=null)
		    			 {
			    			 if(listeOffre.get(j).getStation_Depart().getVilleStations().getIdVille()==IdCiSe)
			    			 {
			    				 pkcity=true;
			    			 }
			    			 else
			    			 {
			    				 pkcity=false;
			    			 }
		    			 }
		    			 else
		    			 {
		    				 pkcity=false;
		    			 }
		
		    		 }
		    		 else
		    		 {
		    		 if(listeOffre.get(j).getVilleArrive().getIdVille()==IdCiSe)
		    		 {
		    			 pkcity=true;
		    		 }
		    		 else
		    		 {
		    			 pkcity=false;
		    		 }
		    		 }
		    	 }
		    	 
		    	//delivery
		    	 //test delivery country
		    	 if(IdCcmSe!=0)
		    	 {
		    		 if(typeR.compareTo("DoorToPort")==0 ||  typeR.compareTo("PortToPort")==0)
		    		 {
			    			 if(listeOffre.get(j).getStation_Arrive()!=null)
			    			 {
				    			 if(listeOffre.get(j).getStation_Arrive().getVilleStations().getEtat().getPays().getIdPays()==IdCcmSe)
				    			 {
				    				 dlcountry=true;
				    			 }
				    			 else
				    			 {
				    				 dlcountry=false;
				    			 }
			    			 }
			    			 else
			    			 {
			    				 dlcountry=false;
			    			 }
		
		    		 }
		    		 else
		    		 {
		    		 if(listeOffre.get(j).getVilleArrive().getEtat().getPays().getIdPays()==IdCcmSe)
		    		 {
		    			 dlcountry=true;
		    		 }
		    		 else
		    		 {
		    			 dlcountry=false;
		    		 }
		    		 }
		    	 }
		    	 
		    	 //test delivery state
		    	 
		    	 if(IdScmSe!=0)
		    	 {
		    		 if(typeS.compareTo("DoorToPort")==0 ||  typeS.compareTo("PortToPort")==0)
		    		 {
		    			 
		    			 if(listeOffre.get(j).getStation_Arrive()!=null)
		    			 {
		    			 if(listeOffre.get(j).getStation_Arrive().getVilleStations().getEtat().getIdEtat()==IdScmSe)
		    			 {
		    				 dlstate=true;
		    			 }
		    			 else
		    			 {
		    				 dlstate=false;
		    			 }
		    			 }
		    			 else
		    			 {
		    				 dlstate=false;
		    			 }
		
		    		 }
		    		 else
		    		 {
			    		 if(listeOffre.get(j).getVilleArrive().getEtat().getIdEtat()==IdScmSe)
			    		 {
			    			 dlstate=true;
			    		 }
			    		 else
			    		 {
			    			 dlstate=false;
			    		 }
		    		 }
		    	 }
		    	 
		    	 //test delivery city
		    	 if(IdCicmSe!=0)
		    	 {
		    		 
		    		 
		    		 if(typeS.compareTo("DoorToPort")==0 ||  typeS.compareTo("PortToPort")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Arrive()!=null)
		    			 {
		    			 if(listeOffre.get(j).getStation_Arrive().getVilleStations().getIdVille()==IdCicmSe)
		    			 {
		    				 dlcity=true;
		    			 }
		    			 else
		    			 {
		    				 dlcity=false;
		    			 }
		    			 }
		    			 else
		    			 {
		    				 dlcity=false;
		    			 }
		
		    		 }
		    		 else
		    		 {
			    		 if(listeOffre.get(j).getVilleArrive().getIdVille()==IdCicmSe)
			    		 {
			    			 dlcity=true;
			    		 }
			    		 else
			    		 {
			    			 dlcity=false;
			    		 }
		    		 }
		    	 }
		    	 //test sub category
		    	 if(IdCategorySe!=0)
		    	 {
		    		 if(listeOffre.get(j).getSubcategory().getIdSubCategorie()==IdCategorySe)
		    		 {
		    			 category=true;
		    		 }
		    		 else
		    		 {
		    			 category=false; 
		    		 }
		    	 }
		    	 //tester l'urgence
		    
		    	 if(listeOffre.get(j).getUrgent()==urgentSe)
		    	 {
		    		 
		    		 urgence=true;
		    	 }
		    	 else
		    	 {
		    		 urgence=false;
		    	 }
		    	 
		    	 //dates
		    	 if(dateDebutSe!=null)
		    	 {
		    		 if(listeOffre.get(j).getDate_Chargement().compareTo(dateDebutSe)>=0)
		    		 {
		    			 datefrom=true;
		    		 }
		    		 else
		    		 {
		    			 datefrom=false;
		    		 }
		    	 }
		    	
		    	 if(DatefinSe!=null)
		    	 {
		    		
		    		 if(listeOffre.get(j).getDate_Chargement().compareTo(DatefinSe)<=0)
		    		 {
		    			 datetill=true;
		    		 }
		    		 else
		    		 {
		    			 datetill=false;
		    		 }
		    		 
		    	 }
		    	
		    	 //tester les port
		    	 if(IdPSea!=0)
		    	 {
		    		 if(listeOffre.get(j).getStation_Arrive()!=null)
		    		 {
		    		 if(listeOffre.get(j).getStation_Arrive().getIdStation()==IdPSea)
		    		 {
		    			 
		    			 stationArrivee=true;
		    		 }
		    		 else
		    		 {
		    			 stationArrivee=false;
		    		 }
		    		 }
		    		 else
		    			 stationArrivee=false; 
		    	 }
		    	 
		    	//tester les port
		    	 if(IdDSea!=0)
		    	 {
		    		 if(listeOffre.get(j).getStation_Depart()!=null)
		    		 {
		    		 if(listeOffre.get(j).getStation_Depart().getIdStation()==IdDSea)
		    		 {
		    			 stationDepart=true;
		    		 }
		    		 else
		    		 {
		    			 stationDepart=false;
		    		 }
		    		 }
		    		 else
		    			 stationDepart=false; 
		    		 
		    	 }
		    	 
		    	 
		     }
		   //pour le type by air
		     else
		     {
		    	 
		    	 //pickup
		    	 //test pickup country
		    	 if(IdCAi!=0)
		    	 {
		    		 if(typeAi.compareTo("AirPortToDoor")==0 ||  typeAi.compareTo("AirPortToAirPort")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Depart()!=null)
		    			 {
		    			 if(listeOffre.get(j).getStation_Depart().getVilleStations().getEtat().getPays().getIdPays()==IdCAi)
		    			 {
		    				 pkcountry=true;
		    			 }
		    			 else
		    			 {
		    				 pkcountry=false;
		    			 }
		    			 }
		    			 else
		    			 {
		    				 pkcountry=false;
		    			 }
		
		    		 }
		    			 
		    		 else
		    		 {
		    		 if(listeOffre.get(j).getVilleDepart().getEtat().getPays().getIdPays()==IdCAi)
		    		 {
		    			 pkcountry=true;
		    		 }
		    		 else
		    		 {
		    			 pkcountry=false;
		    		 }
		    		 }
		    	 }
		    	 
		    	 //test pickup state
		    	 
		    	 if(IdSAi!=0)
		    	 {
		    		 if(typeAi.compareTo("AirPortToDoor")==0 ||  typeAi.compareTo("AirPortToAirPort")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Depart()!=null)
		    			 {
			    			 if(listeOffre.get(j).getStation_Depart().getVilleStations().getEtat().getIdEtat()==IdSAi)
			    			 {
			    				 pkstate=true;
			    			 }
			    			 else
			    			 {
			    				 pkstate=false;
			    			 }
		    			 }
		    			 else
		    			 {
		    				 pkstate=false;
		    			 }
		
		    		 }
			    	 else
			    	 {
			    		 if(listeOffre.get(j).getVilleArrive().getEtat().getIdEtat()==IdSAi)
			    		 {
			    			 pkstate=true;
			    		 }
			    		 else
			    		 {
			    			 pkstate=false;
			    		 }
			    	 }
		    	 }
		    	 
		    	 //test pickup city
		    	 if(IdCiAi!=0)
		    	 {
		    		 if(typeAi.compareTo("AirPortToDoor")==0 ||  typeAi.compareTo("AirPortToAirPort")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Depart()!=null)
		    			 {
			    			 if(listeOffre.get(j).getStation_Depart().getVilleStations().getIdVille()==IdCiAi)
			    			 {
			    				 pkcity=true;
			    			 }
			    			 else
			    			 {
			    				 pkcity=false;
			    			 }
		    			 }
		    			 else
		    			 {
		    				 pkcity=false;
		    			 }
		
		    		 }
		    		 else
		    		 {
		    		 if(listeOffre.get(j).getVilleArrive().getIdVille()==IdCiAi)
		    		 {
		    			 pkcity=true;
		    		 }
		    		 else
		    		 {
		    			 pkcity=false;
		    		 }
		    		 }
		    	 }
		    	 
		    	//delivery
		    	 //test delivery country
		    	 if(IdCcmAi!=0)
		    	 {
		    		 if(typeAi.compareTo("DoorToAirPort")==0 ||  typeAi.compareTo("AirPortToAirPort")==0)
		    		 {
			    			 if(listeOffre.get(j).getStation_Arrive()!=null)
			    			 {
				    			 if(listeOffre.get(j).getStation_Arrive().getVilleStations().getEtat().getPays().getIdPays()==IdCcmAi)
				    			 {
				    				 dlcountry=true;
				    			 }
				    			 else
				    			 {
				    				 dlcountry=false;
				    			 }
			    			 }
			    			 else
			    			 {
			    				 dlcountry=false;
			    			 }
		
		    		 }
		    		 else
		    		 {
		    		 if(listeOffre.get(j).getVilleArrive().getEtat().getPays().getIdPays()==IdCcmAi)
		    		 {
		    			 dlcountry=true;
		    		 }
		    		 else
		    		 {
		    			 dlcountry=false;
		    		 }
		    		 }
		    	 }
		    	 
		    	 //test delivery state
		    	 
		    	 if(IdScmAi!=0)
		    	 {
		    		 if(typeAi.compareTo("DoorToAirPort")==0 ||  typeAi.compareTo("AirPortToAirPort")==0)
		    		 {
		    			 
		    			 if(listeOffre.get(j).getStation_Arrive()!=null)
		    			 {
		    			 if(listeOffre.get(j).getStation_Arrive().getVilleStations().getEtat().getIdEtat()==IdScmAi)
		    			 {
		    				 dlstate=true;
		    			 }
		    			 else
		    			 {
		    				 dlstate=false;
		    			 }
		    			 }
		    			 else
		    			 {
		    				 dlstate=false;
		    			 }
		
		    		 }
		    		 else
		    		 {
			    		 if(listeOffre.get(j).getVilleArrive().getEtat().getIdEtat()==IdScmAi)
			    		 {
			    			 dlstate=true;
			    		 }
			    		 else
			    		 {
			    			 dlstate=false;
			    		 }
		    		 }
		    	 }
		    	 
		    	 //test delivery city
		    	 if(IdCicmAi!=0)
		    	 {
		    		 
		    		 
		    		 if(typeAi.compareTo("DoorToAirPort")==0 ||  typeAi.compareTo("AirPortToAirPort")==0)
		    		 {
		    			 if(listeOffre.get(j).getStation_Arrive()!=null)
		    			 {
		    			 if(listeOffre.get(j).getStation_Arrive().getVilleStations().getIdVille()==IdCicmAi)
		    			 {
		    				 dlcity=true;
		    			 }
		    			 else
		    			 {
		    				 dlcity=false;
		    			 }
		    			 }
		    			 else
		    			 {
		    				 dlcity=false;
		    			 }
		
		    		 }
		    		 else
		    		 {
			    		 if(listeOffre.get(j).getVilleArrive().getIdVille()==IdCicmAi)
			    		 {
			    			 dlcity=true;
			    		 }
			    		 else
			    		 {
			    			 dlcity=false;
			    		 }
		    		 }
		    	 }
		    	 //test sub category
		    	 if(IdCategoryAi!=0)
		    	 {
		    		 if(listeOffre.get(j).getSubcategory().getIdSubCategorie()==IdCategoryAi)
		    		 {
		    			 category=true;
		    		 }
		    		 else
		    		 {
		    			 category=false; 
		    		 }
		    	 }
		    	 //tester l'urgence
		    
		    	 if(listeOffre.get(j).getUrgent()==urgentAi)
		    	 {
		    		 
		    		 urgence=true;
		    	 }
		    	 else
		    	 {
		    		 urgence=false;
		    	 }
		    	 
		    	 //dates
		    	 if(dateDebutAi!=null)
		    	 {
		    		 if(listeOffre.get(j).getDate_Chargement().compareTo(dateDebutAi)>=0)
		    		 {
		    			 datefrom=true;
		    		 }
		    		 else
		    		 {
		    			 datefrom=false;
		    		 }
		    	 }
		    	
		    	 if(DatefinAi!=null)
		    	 {
		    		
		    		 if(listeOffre.get(j).getDate_Chargement().compareTo(DatefinAi)<=0)
		    		 {
		    			 datetill=true;
		    		 }
		    		 else
		    		 {
		    			 datetill=false;
		    		 }
		    		 
		    	 }
		    	
		    	 //tester les port
		    	 if(IdPAirPort!=0)
		    	 {
		    		 if(listeOffre.get(j).getStation_Arrive()!=null)
		    		 {
		    		 if(listeOffre.get(j).getStation_Arrive().getIdStation()==IdPAirPort)
		    		 {
		    			 
		    			 stationArrivee=true;
		    		 }
		    		 else
		    		 {
		    			 stationArrivee=false;
		    		 }
		    		 }
		    		 else
		    			 stationArrivee=false; 
		    	 }
		    	 
		    	//tester les port
		    	 if(IdDAirPort!=0)
		    	 {
		    		 if(listeOffre.get(j).getStation_Depart()!=null)
		    		 {
		    		 if(listeOffre.get(j).getStation_Depart().getIdStation()==IdDAirPort)
		    		 {
		    			 stationDepart=true;
		    		 }
		    		 else
		    		 {
		    			 stationDepart=false;
		    		 }
		    		 }
		    		 else
		    			 stationDepart=false; 
		    		 
		    	 }
		     }
		     
		     

		     if(urgence && pkcountry && pkcity && pkstate && dlcity && dlcountry && dlstate && category && datefrom && datetill && stationArrivee && stationDepart)
		     {
	    		System.out.println("add");
		    	 liste.add(listeOffre.get(j));
		     }
		    
		     }
		     
		   System.out.println(liste.size());
		     
			 return liste;
		 }
		 
		//liste des stations :0 pour les gares,1 pour les ports et 2 pour les airport
		 public List<Station> listeStation(Integer i)
		 {
			 System.out.println("listestation"+i+"liste"+metierStation.getAllActiveStation(i).size());
			return metierStation.getAllActiveStation(i);
		 }
		 //action qui se déclenche une fois le type de transport est choisis
		 //i=0  pour by rails,i=1 pour by air et enfin i=3 pour  by sea
		 public void onChangeType(Long i)
		 {
		
			 //pour le type by Rail
			 if(i==0)
			 {
				 if(typeR.compareTo("DoorToDoor")==0)
				 {
					 redredPRail=true;
					 redredDRail=true;
					 
					 redredSDRail=false;
					 redredSPRail=false;
					 
					 
					 //Station de départ 
					 IdPRail=new Integer(0);
					 //Station d'arrivée
					 IdDRail=new Integer(0);
				 }
				 else if(typeR.compareTo("DoorToStation")==0)
				 {
					 listeGareD=listeStation(0);
					 redredPRail=true;
					 redredDRail=true;
					 
					 redredSDRail=true;
					 redredSPRail=false;
					 
					 
					//Station de départ
					 IdPRail=new Integer(0);
				
					 
					 
				 }
				 else if(typeR.compareTo("StationToDoor")==0)
				 {
					 listeGareP=listeStation(0);
					 
					 redredPRail=true;
					 redredDRail=true;
					 
					 redredSDRail=false;
					 redredSPRail=true;
					 
					//Station d'arrivée
					 IdDRail=new Integer(0);
					 
					 
					 
				 }
				 else if(typeR.compareTo("StationToStation")==0)
				 {
					 
					 listeGareP=listeStation(0);
					 listeGareD=listeStation(0);
					 
					 redredPRail=true;
					 redredDRail=true;
					 
					 redredSDRail=true;
					 redredSPRail=true;
					 
					 
					
				 }
				 else
				 {
					 
					 redredPRail=false;
					 redredDRail=false;
					 
					 redredSDRail=false;
					 redredSPRail=false;
					 
					//lieu de départ
					 IdCRa=new Integer(0);
					 IdSRa=new Integer(0);
					 IdCiRa=new Integer(0);
					 
					//lieu d'arrivée
					 IdCcmRa=new Integer(0);
					 IdScmRa=new Integer(0);
					 IdCicmRa=new Integer(0);
					 
					 IdDRail=new Integer(0);
					 IdPRail=new Integer(0);
				 }
				 
				 
			 }
			 if(i==1)
			 {
				 
				 if(typeS.compareTo("DoorToDoor")==0)
				 {
					
					 redredPSea=true;
					 redredDSea=true;
					 
					 redredSDSea=false;
					 redredSPSea=false;
					 
					 
					 //Station de départ 
					 IdPSea=new Integer(0);
					 //Station d'arrivée
					 IdDSea=new Integer(0);
					 
					 
					 
				 }
				 else if(typeS.compareTo("DoorToPort")==0)
				 {
					 listePortD=listeStation(1);
					 
					 redredPSea=true;
					 redredDSea=true;
					 
					 redredSDSea=true;
					 redredSPSea=false;
					 
					 
					//Station de départ
					 IdPSea=new Integer(0);
					 
					 
					
				 }
				 else if(typeS.compareTo("PortToDoor")==0)
				 {
					 listePortP=listeStation(1);
					 
					 redredPSea=true;
					 redredDSea=true;
					 
					 redredSDSea=false;
					 redredSPSea=true;
					 
					//Station d'arrivée
					 IdDSea=new Integer(0);
					 
					 

				 }
				 else if(typeS.compareTo("PortToPort")==0)
				 {
					 
					 listePortD=listeStation(1);
					 listePortP=listeStation(1);
					 
					 
					 redredPSea=true;
					 redredDSea=true;
					 
					 
					 redredSDSea=true;
					 redredSPSea=true;
					 

				 }
				 else
				 {
					 
					 
					 redredPSea=false;
					 redredDSea=false;
					 
					 redredSDSea=false;
					 redredSPSea=false;
					 
					//lieu de départ
					 IdCSe=new Integer(0);
					 IdSSe=new Integer(0);
					 IdCiSe=new Integer(0);
					 
					//lieu d'arrivée
					 IdCcmSe=new Integer(0);
					 IdScmSe=new Integer(0);
					 IdCicmSe=new Integer(0);
					 
					 IdDSea=new Integer(0);
					 IdPSea=new Integer(0);
					 
				 }
				 
			 }
			 if(i==2)
			 {
				 if(typeAi.compareTo("DoorToDoor")==0)
				 {
					 
					 redredPAir=true;
					 redredDAir=true;
					 
					 redredSDAir=false;
					 redredSPAir=false;
					 
					 
					 //Station de départ 
					 IdPAirPort=new Integer(0);
					 //Station d'arrivée
					 IdDAirPort=new Integer(0);
					 

				 }
				 else if(typeAi.compareTo("DoorToAirPort")==0)
				 {
					 
					 ListeAiD=listeStation(2);
					 
					 redredPAir=true;
					 redredDAir=true;
					 
					 redredSDAir=true;
					 redredSPAir=false;
					 
					 
					//Station de départ
					 IdPAirPort=new Integer(0);
					 
				 }
				 else if(typeAi.compareTo("AirPortToDoor")==0)
				 {
					 ListeAirP=listeStation(2);
					 redredPAir=true;
					 redredDAir=true;
					 
					 redredSDAir=false;
					 redredSPAir=true;
					 
					//Station d'arrivée
					 IdDAirPort=new Integer(0);
				 }
				 else if(typeAi.compareTo("AirPortToAirPort")==0)
				 {
					 ListeAirP=listeStation(2);
					 ListeAiD=listeStation(2);
					 
					 redredPAir=true;
					 redredDAir=true;
					 
					 
					 redredSDAir=true;
					 redredSPAir=true;
				 }
				 
				 else
				 {
					 redredPAir=false;
					 redredDAir=false;
					 
					 redredSDAir=false;
					 redredSPAir=false;
					 
					//lieu de départ
					 IdCAi=new Integer(0);
					 IdSAi=new Integer(0);
					 IdCiAi=new Integer(0);
					 
					//lieu d'arrivée
					 IdCcmAi=new Integer(0);
					 IdScmAi=new Integer(0);
					 IdCicmAi=new Integer(0);
					 
					 IdDAirPort=new Integer(0);
					 IdPAirPort=new Integer(0);
				 }
				 
			 }
				 
				 
		 }
		 
		 //fonction qui permet d'archiver les offres
		 //fonction qui permet de détécter les déclarations ganante pour chaque offre
			//programme qui archive les offres
			public void archive()
			{
				List<Offre> listeOffre=metier.listeOffre(1,null,0) ;
				System.out.println("archive"+listeOffre.size());
				for(int i=0;i<listeOffre.size();i++)
				{
					
					if((listeOffre.get(i).getDecGanante()==null) && (listeOffre.get(i).getDate_Expiration().compareTo(new Date()) < 0) )
					{
						
						System.out.println("lool");
						Offre o=listeOffre.get(i);
						o.setStatutOffre(6);
						metier.updateOffre(o);
						Message m=new Message("Offre archived", ((Employe)metierClient.getUtilisateur(34)), o.getExpediteur(), "your shipment "+o.getIdOffre()+" is archived",new Date());
						metierMessage.addMessage(m);
						
					}
					
				}
			
			}

			//envoyer un message au transporteur lorsqu'une déclaration a gagné
			public void DeclarationGagner()
			{
				
				List<Offre> listeOffre=metier.listeOffre(1,null,0) ;
				for(int i=0;i<listeOffre.size();i++)
				{
				//////////////
					 List<Declaration> ld=metierDec.getDeclarationGagnante(listeOffre.get(i));
					  //teser la dernière déclaration pour savoir si l'offre doit etre archivé ou pas
					  if(ld.size()!=0)
					  {
						  
						  if(ld.get(0).getPrice() <= listeOffre.get(i).getPrix_desire())
						  {
						 
						  Date DQMP=ld.get(0).getDateCreation();
						  
						  Date date = new Date();
						  
						  Calendar cal = Calendar.getInstance();
						  Calendar cal1 = Calendar.getInstance();
						    
						  cal1.setTime(date);
						  cal.setTime(DQMP);
						    
						  cal.add(Calendar.MINUTE, minutes);
						  
						    //régler le probleme de l'heur
						//  cal1.add(Calendar.HOUR, 1);
						  if(cal.getTime().compareTo(cal1.getTime())<=0)
						  {
							  
						
							//ajouter la declaration gagnante
							
							//envoyer à un transporteur
							Message mt=new Message("bid winner", ((Employe)metierClient.getUtilisateur(34)), ld.get(0).getTransporteur(),"the bid"+ld.get(0)+"is the winner accept the bid ",new Date()); 
							//anvoyer à l'expéditeur
							Message me=new Message("bid winner", ((Employe)metierClient.getUtilisateur(34)), ld.get(0).getOffre().getExpediteur(),"the bid"+ld.get(0)+"is the winner accept the bid ",new Date()); 
							
							metierMessage.addMessage(mt);
							metierMessage.addMessage(me);
							
							
						  }
						
						  }
						  
					  }
					
			    /////////////
					  
					
				}
				
				
			}
		 
}
